"""
超级管理员相关
"""
import json
import pickle
import traceback
import logging
from datetime import datetime
from io import BytesIO
import random

from flask import Blueprint, request, g, make_response
from flask_restful import Resource, Api, reqparse, marshal, fields, current_app

from common.utils.custom_output_json import custom_output_json
from common.utils.jwt_util import _generate_token, refresh_token
from common.models import rds, db, cache
from common.models.user import VIP
from common.model_fields.user_fields import user_fields, vip_fields
from common.utils.utils import generate_code
from common.utils.login_util import check_code

vip_bp = Blueprint('vip_bp', __name__, url_prefix='/vip')
api = Api(vip_bp)


@api.representation('application/json')
def output_json(data, code=200, headers=None):
    return custom_output_json(data, code, headers)


class VipList(Resource):
    """
    获取vip等级列表
    """
    def get(self):
        vip_list = VIP.query.all()
        return marshal(vip_list, vip_fields)


api.add_resource(VipList, '/get_vip_list', endpoint='get_vip_list')
